package com.codejoys.config;

import com.codejoys.Utils.DateUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

//指定包扫描的路径
//注册bean
@Configuration    //代表这是一个配置类
@ComponentScan({"com.codejoys.mapper", "com.codejoys.service"
        , "com.codejoys.Utils", "com.codejoys.web"})
//spring管理的bean都是component
public class AppConfig {
    @Bean //使用Bean注解，注册一个Bean
    public DateUtils createDateUtils() {
        System.out.println("Bean注解.,,.,.,.,");
        return new DateUtils();
    }

    @Bean
    public DateFormat createDateFormat() {
        return new SimpleDateFormat("yyyy-M-dd");
    }
}
